<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/datapicker/bootstrap-datetimepicker.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/awesome-bootstrap-checkbox/0.3.7/awesome-bootstrap-checkbox.min.css" rel="stylesheet">
<title>添加会员</title>
<style type="text/css">
.radio{margin-top: 0;}
.radio-primary input[type="radio"] + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::after {background-color: #1ab394;}
.radio-primary input[type="radio"]:checked + label::before {border-color: #1ab394;}
</style>
</head>
<body>
<form id="memberSaveForm" method="post" class="form-horizontal">
	<div class="row">
	    <div class="form-group">
	        <label class="col-sm-2 control-label">会员手机号：</label>
	        <div class="col-sm-4">
	            <input id="phone" name="phone" type="text" class="form-control" maxlength="11" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
	        </div>
	    </div>
	</div>
	<div class="row">
	    <div class="form-group">
	        <label class="col-sm-2 control-label">会员姓名：</label>
	        <div class="col-sm-4">
	            <input name="name" id="name" type="text" class="form-control">
	        </div>
	    </div>
	</div>
	<div class="row">
		<div class="form-group">
	        <label class="col-sm-2 control-label">会员生日：</label>
	        <div class="col-sm-3">
	        	<input id="birthday" name="birthday" value="1900-01-01" readonly="readonly" class="form-control">
	        </div>
		</div>
<!-- 	    <div class="form-group"> -->
<!-- 	        <label class="col-sm-2 control-label">会员生日：</label> -->
<!-- 	        <div class="col-sm-2"> -->
<!-- 	            <select class="form-control year" onchange="func_getDay()"> -->
<!-- 	            </select> -->
<!-- 	        </div> -->
<!-- 	        <div class="col-sm-1" style="padding-left:0;"> -->
<!-- 	            <span style="line-height:34px;">年</span> -->
<!-- 	        </div> -->
<!-- 	        <div class="col-sm-2"> -->
<!-- 	            <select class="form-control month" onchange="func_getDay()"> -->
<!-- 	            </select> -->
<!-- 	        </div> -->
<!-- 	        <div class="col-sm-1" style="padding-left:0;"> -->
<!-- 	            <span style="line-height:34px;">月</span> -->
<!-- 	        </div> -->
<!-- 	        <div class="col-sm-2"> -->
<!-- 	            <select class="form-control day"> -->
<!-- 	            </select> -->
<!-- 	        </div> -->
<!-- 	        <div class="col-sm-1" style="padding-left:0;"> -->
<!-- 	            <span style="line-height:34px;">日</span> -->
<!-- 	        </div> -->
<!-- 	    </div> -->
	</div>
	<div class="row">
	    <div class="form-group">
	        <label class="col-sm-2 control-label">会员性别：</label>
	        <div class="col-sm-1">
	            <div class="radio radio-primary">
	                <input id="a" type="radio" name="gender" value="m">
	                <label for="a">男</label>
	            </div>
	        </div>
	        <div class="col-sm-1">
	            <div class="radio radio-primary">
	                <input id="b" type="radio" name="gender" value="f">
	                <label for="b">女</label>
	            </div>
	        </div>
	    </div>
	</div>
	<div class="row">
	    <div class="form-group">
	        <label class="col-sm-2 control-label">QQ号码：</label>
	        <div class="col-sm-4">
	            <input name="qq" id="qq" type="text" class="form-control">
	        </div>
	    </div>
	</div>
	<div class="row">
	    <div class="form-group">
	        <label class="col-sm-2 control-label">会员类别：</label>
	        <div class="col-sm-2">
	            <div class="radio radio-primary">
	                <input id="c" type="radio" name="isPotential" value="2" checked="checked">
	                <label for="c">潜客</label>
	            </div>
	        </div>
	        <div class="col-sm-2">
	            <div class="radio radio-primary">
	                <input id="d" type="radio" name="isPotential" value="1">
	                <label for="d">会员</label>
	            </div>
	        </div>
	    </div>
	</div>
	<div class="row">
	    <div class="form-group">
	        <label class="col-sm-2 control-label">备注：</label>
	        <div class="col-sm-9">
	        	<textarea name="remarks" style="width: 100%;height: 100px;" class="form-control"></textarea>
	        </div>
	    </div>
	</div>
	<div class="row text-center" style="margin-top:20px;">
	    <button class="btn btn-primary" type="button" onclick="func_saveMember()">保存</button>
	</div>
</form>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/localization/messages_zh.js"></script>
<script type="text/javascript">
var path = "<%=path%>";

$(function(){
	$("#birthday").datetimepicker({startDate:"1900-01-01",language:"zh-CN",format:'yyyy-mm-dd',autoclose:true,minView:2});
});

//会员添加
function func_saveMember() {
	var phone = $("#phone").val();
    if ($.trim(phone) == "") {
        alert("手机号码不能为空");
        return;
    }
    if (!/^1[34578]\d{9}$/.test($.trim(phone))) {
        alert("手机号码不正确");
        return;
    }
    if (!/^[\u4E00-\u9FA5A-Za-z0-9]+$/.test($.trim($("#name").val()))) {
        alert("请填写正确的姓名");
        return;
    }
    if (!/^\d*$/.test($.trim($("#qq").val()))) {
        alert("qq号码不正确");
        return;
    }
    $.post(path+"/member/ajaxMemberSave",$("#memberSaveForm").serialize(),function(data){
    	if(data.status == "200"){
			parent.func_dataTableReload();
    	}else if(data.status == "601"){
    		alert("该条记录已存在");
    		return ;
    	}else{
            alert("插入失败");
    	}
    	parent.saveMemberDialog.remove();
    },"json");
}
</script>
</html>